<?php
namespace App\Logic\SalesReport;
use App\Models\Product\ProductAmazonSkuCCS;
use App\Models\SalesReport\PaymentClassify;
use Illuminate\Support\Facades\DB;
class PaymentClassifyUp
{
    public static function exe(){
        ini_set('memory_limit', '200M');
        set_time_limit(0);
        ProductAmazonSkuCCS::query()->orderBy('id')
            ->chunk(300, function ($pds){
                DB::beginTransaction();
                try{
                    foreach ($pds as $pd){
                        PaymentClassify::query()
                            ->where('country_id',$pd->country_id)
                            ->where('classify_id',$pd->classify_id)
                            ->update(['seller_id' => $pd->seller_id]);
                    }
                    DB::commit();
                }catch (\Exception $e){
                    DB::rollBack();
                    report($e);
                }
            });
        DB::commit();
    }
}
